package day36.edu;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

// Created: 06/10/2025, ChangJiang Ru
public class InetAddressTest {
    @Test
    public void test1() throws UnknownHostException {
        InetAddress inet1 = InetAddress.getByName("www.baidu.com");
        System.out.println(inet1);
        InetAddress inet2 = InetAddress.getByName("www.atguigu.com");
        System.out.println(inet2);

        // Get local host
        InetAddress inet3 = InetAddress.getLocalHost();
        System.out.println(inet3);

        InetAddress inet4 = InetAddress.getByName("127.0.0.1");
        System.out.println(inet4);
    }

    @Test
    public void test2()
    {
        try {
            InetAddress inet1 = InetAddress.getByName("192.168.23.43");
            System.out.println(inet1.getHostName());
            System.out.println(inet1.getHostAddress());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        System.out.println();
    }
}
